import React from "react";
import './App.css';
import { Switch, Route,Redirect } from "react-router-dom"

import { adminRoutes } from './routes'
import Frame from './components/Frame/index'
import {isLogined} from './utils/auth'

  
function App() {
  return (isLogined()?
     <Frame>
      <Switch>
        {
          adminRoutes.map(route => {
            return (<Route key={route.path} 
              path={route.path}
              exact={route.exact}
              render={routerProps=>{
                return<route.component{...routerProps}/>;
              }}/>);
          })
        }
        <Redirect to={adminRoutes[0].path} from="/admin"/>
        <Redirect to="/404"/>
      </Switch>
      </Frame> :(<Redirect to="/Login" />)
  );
}

export default App;
